共计 467 个字符,预计需要花费 2 分钟才能阅读完成。
知乎的每日 60 秒读懂世界停止了更新,图片不能复制新闻内容很麻烦,所以今天教大家弄一个 WordPress 实时新闻 文字版页面。
教程
1. 首先下载文件到网站任意目录
2. 在主题目录的function.php
文件添加如下代码
function display_external_content() {$image_url= '域名 /xinwen/data/60s_'.date('D').'.png';
$url = '域名 /xinwen';
$response = wp_remote_get($url);
$image_html = '
';
$body = wp_remote_retrieve_body($response);
$text_html = '' . $body. '
';
$content_html = $image_html . $text_html;
return $content_html;
}
add_shortcode('baidu_hot_new', 'display_external_content');
3. 在想要展示的页面中添加[baidu_hot_new]
短代码。
正文完